import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '用户ID',
    align:"center",
    dataIndex: 'userId'
   },
   {
    title: '机构名称',
    align:"center",
    dataIndex: 'medicalName'
   },
   {
    title: '科室名称',
    align:"center",
    dataIndex: 'sectionoffice'
   },
   {
    title: '主治病症',
    align:"center",
    dataIndex: 'principally'
   },
   {
    title: '医生姓名',
    align:"center",
    dataIndex: 'name'
   },
   {
    title: '医生性别',
    align:"center",
    dataIndex: 'sex'
   },
   {
    title: '医生年龄',
    align:"center",
    dataIndex: 'age'
   },
   {
    title: '是否推荐',
    align:"center",
    dataIndex: 'recommend_dictText'
   },
   {
    title: '医生视频',
    align:"center",
    dataIndex: 'avi',
    slots: { customRender: 'fileSlot' },
   },
   {
    title: '医生形象',
    align:"center",
    dataIndex: 'avatar',
    customRender:render.renderImage,
   },
   {
    title: '获得荣誉',
    align:"center",
    dataIndex: 'honor',
    customRender:render.renderImage,
   },
   {
    title: '简介',
    align:"center",
    dataIndex: 'biography',
    slots: { customRender: 'htmlSlot' },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "机构名称",
      field: 'medicalName',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"medical",
            fieldConfig: [
                { source: 'id', target: 'medicalId' },
                { source: 'medical_name', target: 'medicalName' },
            ],
            multi:true
        }
    },

      colProps: {span: 6},
 	},
	{
      label: "科室名称",
      field: 'sectionoffice',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seconddisease",
            fieldConfig: [
                { source: 'fristdisease_id', target: 'sectionofficeId' },
                { source: 'firstdisease_name', target: 'sectionoffice' },
                { source: 'id', target: 'principallyId' },
                { source: 'seconddisease_name', target: 'principally' },
            ],
            multi:true
        }
    },

      colProps: {span: 6},
 	},
	{
      label: "主治病症",
      field: 'principally',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seconddisease",
            fieldConfig: [
                { source: 'fristdisease_id', target: 'sectionofficeId' },
                { source: 'firstdisease_name', target: 'sectionoffice' },
                { source: 'id', target: 'principallyId' },
                { source: 'seconddisease_name', target: 'principally' },
            ],
            multi:true
        }
    },

      colProps: {span: 6},
 	},
	{
      label: "医生姓名",
      field: 'name',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "是否推荐",
      field: 'recommend',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"yn"
      },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '用户ID',
    field: 'userId',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"user",
            fieldConfig: [
                { source: 'id', target: 'userId' },
            ],
            multi:true
        }
    },

  },
  {
    label: '机构名称',
    field: 'medicalName',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"medical",
            fieldConfig: [
                { source: 'id', target: 'medicalId' },
                { source: 'medical_name', target: 'medicalName' },
            ],
            multi:true
        }
    },

  },
  {
    label: '科室名称',
    field: 'sectionoffice',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seconddisease",
            fieldConfig: [
                { source: 'fristdisease_id', target: 'sectionofficeId' },
                { source: 'firstdisease_name', target: 'sectionoffice' },
                { source: 'id', target: 'principallyId' },
                { source: 'seconddisease_name', target: 'principally' },
            ],
            multi:true
        }
    },

  },
  {
    label: '主治病症',
    field: 'principally',
    component: 'JPopup',
    componentProps: ({ formActionType }) => {
        const {setFieldsValue} = formActionType;
        return{
            setFieldsValue:setFieldsValue,
            code:"seconddisease",
            fieldConfig: [
                { source: 'fristdisease_id', target: 'sectionofficeId' },
                { source: 'firstdisease_name', target: 'sectionoffice' },
                { source: 'id', target: 'principallyId' },
                { source: 'seconddisease_name', target: 'principally' },
            ],
            multi:true
        }
    },

  },
  {
    label: '医生姓名',
    field: 'name',
    component: 'Input',
  },
  {
    label: '医生性别',
    field: 'sex',
    component: 'Input',
  },
  {
    label: '医生年龄',
    field: 'age',
    component: 'Input',
  },
  {
    label: '是否推荐',
    field: 'recommend',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
  {
    label: '医生视频',
    field: 'avi',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '医生形象',
    field: 'avatar',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '获得荣誉',
    field: 'honor',
     component: 'JImageUpload',
     componentProps:{
      },
  },
  {
    label: '简介',
    field: 'biography',
    component: 'JEditor',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}